<%@ page language="java" contentType="text/html; charset=UTF-8"	pageEncoding="UTF-8" isELIgnored="false"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="chtml" uri="http://www.szhelper.com/jsp/html"%>
<%@ taglib prefix="FCK"  uri="http://java.fckeditor.net" %>
<%@ taglib uri = "/WEB-INF/FCKeditor.tld" prefix = "fck" %> 
<%@ taglib  prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@ page import="java.util.*,com.hengpeng.itfinbase.persist.ArticleCategory"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="zh-CN" lang="zh-CN">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>${article.id == null?"新增":"修改"}文章 </title>
<script type="text/javascript" src="<chtml:path path="/" />herpeleditor/fckeditor.js"></script>
<script type="text/javascript">
	function FCKeditor_OnComplete(editorInstance) {
		window.status = editorInstance.Description;
	}
	jQuery(function(){
		checkSel_author($("#author").val());
	});
	function onsubmits(){
		var acticleGroups_sel_state = false;
		var content_state = false;
		var msg = "";
		//分组空值验证
		var acticleGroups_sel = document.getElementById("acticleGroups");
		for(var i=0;i<acticleGroups_sel.length;i++)
		{
			acticleGroups_sel.options[i].selected = true;
		}
		if(acticleGroups_sel.length>0)
			acticleGroups_sel_state = true;
		else
			msg += "分组不能为空! \n";
			
		if($("#author").val() == -1) {
			var author_self = $("#author_self").val();
			if(author_self == null || author_self.trim() == "") {
				msg += "请输入自定义的作者名称！\n";
			}
		}
		
		var oEditor = FCKeditorAPI.GetInstance('content');  
		 oEditor.Focus();  
		var checkContent = oEditor.GetXHTML();  
		if(checkContent!=""){
			content_state = true;
		}else{
			msg += "新闻内容不能为空！\n";
			}
		if(msg.length>0)
		{
			alert(msg);
			return false;
		}
		return acticleGroups_sel_state&&content_state;
	}
	
	/**
	 * 作者自定义检查
	 **/
	function checkSel_author(sel){
		if(-1 == sel) {
			$("#author_self").show();
		}else {
			$("#author_self").hide();
		}
	}
	
</script>
</head>
<body>
<div class="youarehere">网站内容管理 &gt; <span>管理文章</span>&gt; <span>${article.id == null?"新增":"修改"}文章</span></div>
<c:set var="authors_name" value="开心婷婷,小魔女,轩辕一卜,点彩成精,妖精点彩,六六评彩,彩霸一方,海盗船长,漩涡鸣人,慕容汐儿,至尊宝宝"></c:set>
<c:set var="title_color"  value="黑色:black,蓝色:blue,红色:pink"></c:set>
<c:if test="${article.id == null}">
	<chtml:command command="article" title="新增" action="/am" method="POST" exclude="appUserId,createTime,updateTime,stores,category,realName,author,setTopEndTime,titleColor" onSubmit="onsubmits()">
	<chtml:property index="5" label="头条新闻标题颜色">
		<select id="titleColor" name="titleColor" style="padding: 4px 2px;">
			<option value="black">默认无</option>
			<c:forEach var="color" items="${fn:split(title_color, ',') }">
				<option value="${fn:split(color, ':')[1]}" >${fn:split(color, ':')[0]}</option>
			</c:forEach>
		</select>
	</chtml:property>
	<chtml:property index="10" label="作者">
		<input type="text" style="display: none;" name="author_self" id="author_self" title="请输入作者"></input>
		<select id="author" name="author" onchange="javascript: checkSel_author(this.value);" style="padding: 4px 2px;">
			<option value="">默认是你的昵称--</option>
			<c:forEach var="author_t" items="${fn:split(authors_name, ',') }">
				<option value="${author_t }" >${author_t }</option>
			</c:forEach>
			<option value="-1" style="color:red;">自定义</option>
		</select> <span style="color:red;">*</span>
	</chtml:property>
	
	<chtml:property index="11" label="所属组">
		<table border="0">
	   	  <tr><td>请选择：</td><td style="width: 65px; text-align: center;">&nbsp;&nbsp;</td><td>已选择：</td> </tr>
		  <tr>
			<td>
			<select id="acticleGroup_all" name="acticleGroup_all" multiple="multiple" style="height: 230px;width: 100%;">
				<c:forEach items="${requestScope.groups}" var="group">
					<option value="${group.id }">${group.name }</option>
				</c:forEach>
			</select>
			</td>
			<td style="width: 65px; text-align: center;">
			<a href="#" onclick="javascript:helper.fun.moveSelectItem('acticleGroup_all','acticleGroups');">添加</a><br><br>
			<a href="#" onclick="javascript:helper.fun.moveSelectItem('acticleGroups','acticleGroup_all');">移除</a>
			</td>
			<td>
			<select id="acticleGroups" name="acticleGroups" multiple="multiple" style="height: 230px;width: 100%;"></select>
			</td>
		  </tr>
		 </table>
	</chtml:property>
	<chtml:property index="12" label="首页滚动图片地址">
		<input name="indexImage" id="indexImage" value="" size="60"/>
	</chtml:property>
	<chtml:property index="16" label="首页滚动图片指向" tips="此项若不为空，则点击图片会链接到该地址">
		<input name="url" id="url" value="" size="60"/>
	</chtml:property>
	<chtml:property index="14" label="所属类别">
		<select name="category">
			<c:forEach var="category" items="${categorys }">
				<option value="${category.id }">${category.name }</option>
			</c:forEach>
		</select>
	</chtml:property>
	<chtml:property index="15" label="内容">
		<FCK:editor instanceName="content" >
				<jsp:attribute name="value">
				</jsp:attribute>
		</FCK:editor>
	</chtml:property>
	<chtml:button destination="/am" showText="新增"></chtml:button>
	</chtml:command>
	<script type="text/javascript">
    </script>
</c:if>
<c:if test="${article.id != null}">
	<chtml:command command="article" title="修改" method="POST" action="/am/${article.id}" exclude="appUserId,createTime,updateTime,category,realName,author,setTopEndTime,titleColor" readonly="author" onSubmit="onsubmits()">
	
	<chtml:property index="5" label="头条新闻标题颜色">
		<select id="author" name="titleColor" style="padding: 4px 2px;">
			<option value="black">默认无</option>
			<c:forEach var="color" items="${fn:split(title_color, ',') }">
				<c:if test="${fn:split(color, ':')[1] eq article.titleColor}">
					<option value="${fn:split(color, ':')[1]}" selected="selected">${fn:split(color, ':')[0]}</option>
				</c:if>
				<c:if test="${fn:split(color, ':')[1] ne article.titleColor}">
					<option value="${fn:split(color, ':')[1]}">${fn:split(color, ':')[0]}</option>
				</c:if>
			</c:forEach>
		</select>
	</chtml:property>
	<chtml:property index="10" label="作者">
		<input type="text" style="display: none;" name="author_self" id="author_self" title="请输入作者"></input>
		<select id="author" name="author" onchange="javascript: checkSel_author(this.value);" style="padding: 4px 2px;">
			<option value="">默认是你的昵称--</option>
			<option value="${article.author }" selected="selected">${article.author }</option>
			<c:forEach var="author_t" items="${fn:split(authors_name, ',') }">
				<c:if test="${author_t ne article.author  }">
					<option value="${author_t }" >${author_t }</option>
				</c:if>
			</c:forEach>
			<option value="-1" style="color:red;">自定义</option>
		</select> <span style="color:red;">*</span>
	</chtml:property>
	
	<chtml:property index="11" label="所属组">
		<table border="0">
	   	  <tr><td>请选择：</td><td style="width: 65px; text-align: center;">&nbsp;&nbsp;</td><td>已选择：</td> </tr>
		  <tr>
			<td>
			<select tabindex="2" id="acticleGroup_all" name="acticleGroup_all" multiple="multiple" style="height: 230px;width: 100%;">
				<c:forEach items="${requestScope.diffGroups}" var="group">
					<option value="${group.id }">${group.name }</option>
				</c:forEach>
			</select>
			</td>
			<td style="width: 65px; text-align: center;">
			<a href="#" onclick="javascript:helper.fun.moveSelectItem('acticleGroup_all','acticleGroups');">添加</a><br><br>
			<a href="#" onclick="javascript:helper.fun.moveSelectItem('acticleGroups','acticleGroup_all');">移除</a>
			</td>
			<td>
			<select tabindex="2" id="acticleGroups" name="acticleGroups" multiple="multiple" style="height: 230px;width: 100%;">
				<c:forEach items="${requestScope.groupsSelf}" var="group">
					<option value="${group.id }">${group.name }</option>
				</c:forEach>
			</select>
			</td>
		  </tr>
		 </table>
	</chtml:property>
	<chtml:property index="12" label="首页滚动图片地址">
		<input name="indexImage" id="indexImage" value="${filename}" size="60"/>
	</chtml:property>
	<chtml:property index="16" label="首页滚动图片指向" tips="此项若不为空，则点击图片会链接到该地址">
		<input name="url" id="url" value="${url }" size="60"/>
	</chtml:property>
	<chtml:property index="14" label="所属类别">
		<select name="category">
			<c:forEach var="category" items="${categorys }">
				<c:choose>
					<c:when test="${category.id eq article.category.id }"><option value="${category.id }" selected="selected">${category.name }</option></c:when>
					<c:otherwise><option value="${category.id }">${category.name }</option></c:otherwise>
				</c:choose>
			</c:forEach>
		</select>
	</chtml:property>
	<chtml:property index="15" label="内容">
		<FCK:editor instanceName="content" >
				<jsp:attribute name="value">
					${article.content}
				</jsp:attribute>
		</FCK:editor>
	</chtml:property>
	<chtml:button destination="/am/${article.id}" showText="修改"></chtml:button>
	</chtml:command>
</c:if>
<style type="text/css">
td.data_tab_tdl #fullTitle,#keywords,#title{width:518px;}
</style>
<!--说明   -->	
<div class="sm_info">
	<p class="row_one">说明：</p>
	<p class="other"></p>
	<p class="other"></p>
</div>
</body>
</html>



